// 用于获取提示信息
const T = require("../type");

module.exports = {
    /**
     * @returns {T.Base.Service}
     */
    ServiceType(){},
    /**
     * 添加服务到路由中
     * @param {Object} routers 
     * @param {Object} services 
     */
    appendServices(routers, services) {
        // 添加服务
        let serviceList = Object.keys(services);
        for (const uri in routers) {
            let index = serviceList.indexOf(uri);
            if(-1 < index && typeof services[uri] == "function") {
                routers[uri] = services[uri];
            } else {
                throw new Error(uri + "路由的服务不存在!");
            }
            serviceList.splice(index, 1);
        }
        if(0 < serviceList.length) {
            console.warn("有服务未被启用!", serviceList)
        }
    }
};